package edu.java.lectures.lec13.equals;

public class Person {

    // -- Instance Variables ---------------------------------------------------

    private String name;
    private int age;

    // -- Constructors ---------------------------------------------------------

    public Person(String name, int age) {
	this.name = name;
	this.age = age;
    }

    // --- Getters and Setters -------------------------------------------------

    public String getName() {
	return name;
    }

    public void setName(String name) {
	this.name = name;
    }

    public int getAge() {
	return age;
    }

    public void setAge(int age) {
	this.age = age;
    }

    // -- Methods --------------------------------------------------------------

    @Override
    public boolean equals(Object obj) {
	if (this == obj) {
	    return true;
	}
	if ((obj instanceof Person)) {
	    Person otherPerson = (Person) obj;
	    boolean isEquals = getName().equals(otherPerson.getName())
		    && getAge() == otherPerson.getAge();
	    return isEquals;
	}
	return false;
    }

    @Override
    public int hashCode() {
	return super.hashCode();
    }
}
